const express = require('express');
const router = express.Router();

const userController = require('../controllers/userController');
const { verifyAuthToken } = require('../middlewares/auth/verifyAuth');

// 用户注册路由
const { verifyRegister , hashPassword } = require('../middlewares/user/verifyRegister');
router.post('/register', verifyRegister, hashPassword, userController.register);

// 用户登录路由
const { verifyLogin } = require('../middlewares/user/verifyLogin');
const { loginLimiter } = require('../middlewares/rateLimitMiddleware');
router.post('/login', loginLimiter, verifyLogin, userController.login);

// 获取用户列表
router.get('/list', verifyAuthToken, userController.getUserList);

// 用户详情路由
router.get('/:id', verifyAuthToken, userController.getUserById);

// 用户更新路由
const { verifyUpdateUser } = require('../middlewares/user/verifyRegister');
router.post('/update', verifyAuthToken, verifyUpdateUser, userController.updateUser);

// 用户删除路由
const { verifyDeleteUser } = require('../middlewares/user/verifyDelete');
router.post('/delete', verifyAuthToken, verifyDeleteUser, userController.deleteUser);





module.exports = router;